<?php
    $now = new DateTime();
    $dayNow = (int)$now->format('j');
    $checkNom = null;
    echo    '<table class="tabInfos">
                <caption>Détails</caption>
                <thead>
                    <tr>
                      <th>Machine</th>
                      <th>Service</th>
                      <th>Status</th>
                      <th>Dernier check</th>
                      <th>Durée</th>
                      <th>Informations</th>
                    </tr>
                </thead>
                <tbody>';
    foreach($evenements as $evenement) {
		$stringToDate = $evenement->getDateEvenement('object');
        $interval = $stringToDate->diff($now);
        $dayRow = (int)$stringToDate->format('j');
        $lastModif = $interval->d."j ". $interval->h ."h ". $interval->i ."m ". $interval->s ."s";
		echo        '<tr>';
        if($checkNom != $evenement->getMachine()){
            echo        '<td>'.
                            $evenement->getMachine()
                        .'</td>';
        }
        else{
            echo        '<td></td>';
        }
        echo            '<td>'.$evenement->getTypeEvenement().'</td>
                        <td>'.$evenement->getCriticite().'</td>
                        <td>'.$evenement->getDateEvenement('Y-m-d H:i:s').'</td>
                        <td>'. $lastModif .'</td>
                        <td>
                            <p>' .$evenement->getDonneeEvenement(). '</p>
                        </td>
                    </tr>';
        $checkNom = $evenement->getMachine();
    }
    echo        '</tbody>
            </table>';
?>